#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    unsigned int x, n, now = 1, cnt = 0;
    cin >> x >> n;
    for (int i = 0; i <= n; ++i)
        cnt += now, now = x * cnt;
    cout << cnt;
    return 0;
}